<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="htmlId">
<head>
    <title>Coverage Report :: Pinky</title>
    <style type="text/css">
        @import "../../.css/coverage.css";
    </style>
</head>

<body>
<div class="header"></div>

<div class="content">
    <div class="breadCrumbs">
        [ <a href="../../index.html">all classes</a> ]
        [ <a href="../index.html">nl.tudelft.jpacman.npc.ghost</a> ]
    </div>

    <h1>Coverage Summary for Class: Pinky (nl.tudelft.jpacman.npc.ghost)</h1>

    <table class="coverageStats">
        <tr>
            <th class="name">Class</th>
            <th class="coverageStat
">
                Class, %
            </th>
            <th class="coverageStat
">
                Method, %
            </th>
            <th class="coverageStat
">
                Line, %
            </th>
        </tr>
        <tr>
            <td class="name">Pinky</td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 1)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 3)
  </span>
            </td>
            <td class="coverageStat">
  <span class="percent">
    0%
  </span>
                <span class="absValue">
    (0/ 12)
  </span>
            </td>
        </tr>

    </table>

    <br/>
    <br/>


    <div class="sourceCode"><i>1</i>&nbsp;package nl.tudelft.jpacman.npc.ghost;
        <i>2</i>&nbsp;
        <i>3</i>&nbsp;import java.util.List;
        <i>4</i>&nbsp;import java.util.Map;
        <i>5</i>&nbsp;import java.util.Optional;
        <i>6</i>&nbsp;
        <i>7</i>&nbsp;import nl.tudelft.jpacman.board.Direction;
        <i>8</i>&nbsp;import nl.tudelft.jpacman.board.Square;
        <i>9</i>&nbsp;import nl.tudelft.jpacman.board.Unit;
        <i>10</i>&nbsp;import nl.tudelft.jpacman.level.Player;
        <i>11</i>&nbsp;import nl.tudelft.jpacman.npc.Ghost;
        <i>12</i>&nbsp;import nl.tudelft.jpacman.sprite.Sprite;
        <i>13</i>&nbsp;
        <i>14</i>&nbsp;/**
        <i>15</i>&nbsp; * &lt;p&gt;
        <i>16</i>&nbsp; * An implementation of the classic Pac-Man ghost Speedy.
        <i>17</i>&nbsp; * &lt;/p&gt;
        <i>18</i>&nbsp; * &lt;p&gt;
        <i>19</i>&nbsp; * Nickname: Pinky. Speedy gets his name for an unusual reason. Speedy appears
        <i>20</i>&nbsp; * to try to outsmart Pac-Man and crash into Pac-Man from the opposite
        <i>21</i>&nbsp; * direction. The truth behind this is that when Speedy isn&#39;t patrolling the
        <i>22</i>&nbsp; * top-left corner of the maze, he tries to attack Pac-Man by moving to where he
        <i>23</i>&nbsp; * is going to be (that is, a few spaces ahead of Pac-Man&#39;s current direction)
        <i>24</i>&nbsp; * instead of right where he is, as Blinky does. It&#39;s difficult to use this to
        <i>25</i>&nbsp; * your advantage, but it&#39;s possible. If Pinky is coming at you and you face a
        <i>26</i>&nbsp; * different direction, even briefly, he may just turn away and attempt to cut
        <i>27</i>&nbsp; * you off in the new direction while you return to your original direction. In
        <i>28</i>&nbsp; * the original Japanese version, his name is Machibuse/Pinky.
        <i>29</i>&nbsp; * &lt;/p&gt;
        <i>30</i>&nbsp; * &lt;p&gt;
        <i>31</i>&nbsp; * &lt;b&gt;AI:&lt;/b&gt; When the ghosts are not patrolling their home corners, Pinky wants
        <i>32</i>&nbsp; * to go to the place that is four grid spaces ahead of Pac-Man in the direction
        <i>33</i>&nbsp; * that Pac-Man is facing. If Pac-Man is facing down, Pinky wants to go to the
        <i>34</i>&nbsp; * location exactly four spaces below Pac-Man. Moving towards this place uses
        <i>35</i>&nbsp; * the same logic that Blinky uses to find Pac-Man&#39;s exact location. Pinky is
        <i>36</i>&nbsp; * affected by a targeting bug if Pac-Man is facing up - when he moves or faces
        <i>37</i>&nbsp; * up, Pinky tries moving towards a point up, and left, four spaces.
        <i>38</i>&nbsp; * &lt;/p&gt;
        <i>39</i>&nbsp; * &lt;p&gt;
        <i>40</i>&nbsp; * &lt;i&gt;Note: In the original arcade series, the ghosts&#39; genders are unspecified
        <i>41</i>&nbsp; * and assumed to be male. In 1999, the USA division of Namco and Namco Hometech
        <i>42</i>&nbsp; * developed the Pac-Man World series and declared Pinky to be female.&lt;/i&gt;
        <i>43</i>&nbsp; * &lt;/p&gt;
        <i>44</i>&nbsp; * &lt;p&gt;
        <i>45</i>&nbsp; * Source: http://strategywiki.org/wiki/Pac-Man/Getting_Started
        <i>46</i>&nbsp; * &lt;/p&gt;
        <i>47</i>&nbsp; *
        <i>48</i>&nbsp; * @author Jeroen Roosen
        <i>49</i>&nbsp; *
        <i>50</i>&nbsp; */
        <b class="nc"><i>51</i>&nbsp;public class Pinky extends Ghost {</b>
        <i>52</i>&nbsp;
        <i>53</i>&nbsp; private static final int SQUARES_AHEAD = 4;
        <i>54</i>&nbsp;
        <i>55</i>&nbsp; /**
        <i>56</i>&nbsp; * The variation in intervals, this makes the ghosts look more dynamic and
        <i>57</i>&nbsp; * less predictable.
        <i>58</i>&nbsp; */
        <i>59</i>&nbsp; private static final int INTERVAL_VARIATION = 50;
        <i>60</i>&nbsp;
        <i>61</i>&nbsp; /**
        <i>62</i>&nbsp; * The base movement interval.
        <i>63</i>&nbsp; */
        <i>64</i>&nbsp; private static final int MOVE_INTERVAL = 200;
        <i>65</i>&nbsp;
        <i>66</i>&nbsp; /**
        <i>67</i>&nbsp; * Creates a new &quot;Pinky&quot;, a.k.a. &quot;Speedy&quot;.
        <i>68</i>&nbsp; *
        <i>69</i>&nbsp; * @param spriteMap
        <i>70</i>&nbsp; * The sprites for this ghost.
        <i>71</i>&nbsp; */
        <i>72</i>&nbsp; public Pinky(Map&lt;Direction, Sprite&gt; spriteMap) {
        <b class="nc"><i>73</i>&nbsp; super(spriteMap, MOVE_INTERVAL, INTERVAL_VARIATION);</b>
        <i>74</i>&nbsp; }
        <i>75</i>&nbsp;
        <i>76</i>&nbsp; /**
        <i>77</i>&nbsp; * {@inheritDoc}
        <i>78</i>&nbsp; *
        <i>79</i>&nbsp; * &lt;p&gt;
        <i>80</i>&nbsp; * When the ghosts are not patrolling their home corners, Pinky wants to go
        <i>81</i>&nbsp; * to the place that is four grid spaces ahead of Pac-Man in the direction
        <i>82</i>&nbsp; * that Pac-Man is facing. If Pac-Man is facing down, Pinky wants to go to
        <i>83</i>&nbsp; * the location exactly four spaces below Pac-Man. Moving towards this place
        <i>84</i>&nbsp; * uses the same logic that Blinky uses to find Pac-Man&#39;s exact location.
        <i>85</i>&nbsp; * Pinky is affected by a targeting bug if Pac-Man is facing up - when he
        <i>86</i>&nbsp; * moves or faces up, Pinky tries moving towards a point up, and left, four
        <i>87</i>&nbsp; * spaces.
        <i>88</i>&nbsp; * &lt;/p&gt;
        <i>89</i>&nbsp; */
        <i>90</i>&nbsp; @Override
        <i>91</i>&nbsp; public Optional&lt;Direction&gt; nextAiMove() {
        <b class="nc"><i>92</i>&nbsp; assert hasSquare();</b>
        <i>93</i>&nbsp;
        <b class="nc"><i>94</i>&nbsp; Unit player = Navigation.findNearest(Player.class, getSquare());</b>
        <b class="nc"><i>95</i>&nbsp; if (player == null) {</b>
        <b class="nc"><i>96</i>&nbsp; return Optional.empty();</b>
        <i>97</i>&nbsp; }
        <b class="nc"><i>98</i>&nbsp; assert player.hasSquare();</b>
        <b class="nc"><i>99</i>&nbsp; Square destination = player.squaresAheadOf(SQUARES_AHEAD);</b>
        <i>100</i>&nbsp;
        <b class="nc"><i>101</i>&nbsp; List&lt;Direction&gt; path = Navigation.shortestPath(getSquare(), destination,
            this);</b>
        <b class="nc"><i>102</i>&nbsp; if (path != null &amp;&amp; !path.isEmpty()) {</b>
        <b class="nc"><i>103</i>&nbsp; return Optional.ofNullable(path.get(0));</b>
        <i>104</i>&nbsp; }
        <b class="nc"><i>105</i>&nbsp; return Optional.empty();</b>
        <i>106</i>&nbsp; }
        <i>107</i>&nbsp;}
    </div>
</div>

<div class="footer">

    <div style="float:right;">generated on 2023-04-25 16:45</div>
</div>
</body>
</html>
